package src;

import java.util.Random;

public class Conbat {
    //设定即将创立角色的名称和血量
    private String name;
    private int blood;
    private String face;
    private char gender;

    String[] boyface = {"磕碜","丑陋","端正","狰狞","帅气"};
    String[] grilface = {"美丽","闭月","端正","简陋","凶恶"};
    String[] kongfu = {
            "%s一招左正登，正中%s面门",
            "%s一记右鞭腿，直冲%s天灵盖",
            "%s上去就张开了自己八二年的老黄牙，狠狠咬在%s的屁股上面",
            "%s用出一招【混元功法】，打得%s连退数步",
            "%s甩出几枚手里剑，直奔%s命脉而去",
            "%s一招i大威天龙，将%s拍在地上",
            "%s使出蛤蟆神功，头追顶向%s",
            "%s飞向空中，使出一招从天而降的掌法，拍了%s一下",
            "%s口中念念有词，口吐烈焰点燃%s"};

    String[] status = {
            "，%s被打，后退数十步，抖了抖身上的灰尘",
            "，给%s造成了一处瘀伤",
            "，一击命中，%s疼的弯下了腰",
            "，%s大叫起来，显然很疼",
            "，%s扶墙歇息，显然受到很严重的伤",
            "，%s脸色变得惨白，摇摇晃晃退了几步",
            "，只听轰隆的一声，%s口吐鲜血",
            "，%s哈哈哈大笑三声，竟也还是摇摇晃晃的站起身",
            "，%s捂头痛苦，快速起身",
            "，%s一声惨叫，如同软泥一般倒了下去",};
    //定义空参
    public Conbat() {
    }


    public Conbat(String name, int blood  , char gender) {
        this.name = name;
        this.blood = blood;
        this.gender = gender;

        Random r = new Random();
        //长相判断

        if (gender == '男'){
            int b = r.nextInt(5);
            this.face = boyface[b];
        } else if (gender == '女') {
            int c = r.nextInt(5);
            this.face = grilface[c];
        }else {
            this.face = face;
        }
    }
    //长相
    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public String getFace() {
        return face;
    }

    public void setFace(char gender) {

    }

    //定义全参

    //向外界输出角色的名字
    public String getName() {
        return name;
    }

    //接受外界的输入名，在定义后赋值给成员变量
    public void setName(String name) {
        this.name = name;
    }

    //向外界输出角色的血量
    public int getBlood() {
        return blood;
    }

    //接受外界的输入血量，在定义后赋值给成员变量
    public void setBlood(int blood) {
        this.blood = blood;
    }

    //定义方法  体现角色两人打斗
    //形参输入的是被攻击的人的 参数
    public void attr(Conbat conbat) {
        //造成 1 到 20 滴血随机
        Random r = new Random();
        int num = r.nextInt(kongfu.length);
        String gongfu = kongfu[num];
        System.out.printf(gongfu,this.getName() , conbat.getName());

        int hurt = r.nextInt(10) + 1;
        //剩下的血量需要定义
        int oldblood = conbat.getBlood() - hurt;
        //剩余血量判断，不能小于0
        int a = oldblood < 0 ? 0 : oldblood;
        //将剩余的血量定义近被攻击者的数值中，以便后面进行修改
        conbat.setBlood(a);

        System.out.printf("造成了%d点伤害",hurt);

        if (oldblood > 90 && oldblood < 100) {
            System.out.printf(status[0], conbat.getName());
        }if (oldblood > 80 && oldblood < 90) {
            System.out.printf(status[1], conbat.getName());
        }if (oldblood > 70 && oldblood < 80) {
            System.out.printf(status[2], conbat.getName());
        }if (oldblood > 60 && oldblood < 70) {
            System.out.printf(status[3], conbat.getName());
        }if (oldblood > 50 && oldblood < 60) {
            System.out.printf(status[4], conbat.getName());
        }if (oldblood > 40 && oldblood < 50) {
            System.out.printf(status[5], conbat.getName());
        }if (oldblood > 30 && oldblood < 40) {
            System.out.printf(status[6], conbat.getName());
        }if (oldblood > 20 && oldblood < 30) {
            System.out.printf(status[7], conbat.getName());
        }if (oldblood > 10 && oldblood < 20) {
            System.out.printf(status[8], conbat.getName());
        }if (oldblood > 0 && oldblood < 10) {
            System.out.printf(status[9], conbat.getName());
        }
        System.out.println();

    }
}